package chapter06


/**
 * 抽象类
 * 抽象属性和方法
 */
object Test09_AbstractClass {
  def main(args: Array[String]): Unit = {
    val student = new Student9
    student.eat()
    student.sleep()
  }
}


//定义抽象
abstract class Person9 {

  //非抽象属性
  var name: String = "person"

  //抽象属性
  var age: Int

  //非抽象方法
  def eat(): Unit = {
    println("person eat")
  }

  //抽象方法
  def sleep(): Unit

}


//定义具体的实现类
class Student9 extends Person9 {

  //抽象方法属性直接赋值
  var age: Int = 18

  override def sleep(): Unit = {
    super.eat()
    println("Student sleep")
  }


  //非抽象方法和属性需要重写才可以使用
  //  val  name: String = "student"
  name = "student"

  override def eat(): Unit = {
    println("student eat")
  }

}




